/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * ConsultaProducao.java
 *
 * Created on 02/11/2011, 15:06:25
 */
package praticav.view;

import java.util.Locale;
import java.util.Vector;
import javax.persistence.Column;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
import praticav.dao.AtividadesPlanejadasDAO;
import praticav.dao.AtividadesRealizadasDAO;
import praticav.dao.FasesDAO;
import praticav.dao.ProducaoDAO;
import praticav.dao.TipoUvaDAO;
import praticav.model.AtividadesPlanejadas;
import praticav.model.AtividadesPlanejadasPK;
import praticav.model.AtividadesRealizadas;
import praticav.model.AtividadesRealizadasPK;
import praticav.model.Fases;
import praticav.model.FasesPK;
import praticav.model.Producao;
import sun.net.www.content.text.plain;

/**
 *
 * @author Jonatah Benatti
 */
public class ConsultaProducao extends javax.swing.JFrame {
    int ProCodigo=0;
    int FasCodigo=0;
    int AtiPlanCodigo=0;
    int AtiRelCodigo=0;
    int ano;
    int tipo;
    int quant;
    int conta;
    /** Creates new form ConsultaProducao */
    public ConsultaProducao() {
        initComponents();
        conta=0;
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel1 = new javax.swing.JPanel();
        btnNovaProducao = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        jLabel1 = new javax.swing.JLabel();
        jTextField1 = new javax.swing.JTextField();
        jTextField2 = new javax.swing.JTextField();
        jTextField3 = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        cbxTipoUva = new javax.swing.JComboBox();
        jLabel6 = new javax.swing.JLabel();
        jTextField4 = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        jTextField5 = new javax.swing.JTextField();
        btnPesquisarProducao = new javax.swing.JButton();
        btnModificar = new javax.swing.JButton();
        btnRemover = new javax.swing.JButton();
        jPanel2 = new javax.swing.JPanel();
        jLabel8 = new javax.swing.JLabel();
        txtFasDtaFinalFinal = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        txtFasDescricao = new javax.swing.JTextField();
        txtFasDtaInicialInicial = new javax.swing.JTextField();
        jLabel12 = new javax.swing.JLabel();
        txtFasCodigo = new javax.swing.JTextField();
        jLabel13 = new javax.swing.JLabel();
        txtFasDtaFinalInicial = new javax.swing.JTextField();
        jLabel14 = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTable2 = new javax.swing.JTable();
        btnNovaFase = new javax.swing.JButton();
        txtFasDtaIncialFinal = new javax.swing.JTextField();
        btnPesquisarFase = new javax.swing.JButton();
        btnModificarFase = new javax.swing.JButton();
        btnRemoverFase = new javax.swing.JButton();
        jPanel3 = new javax.swing.JPanel();
        txtAtiDtaFinalFinal = new javax.swing.JTextField();
        btnPesquisarPlanejadas = new javax.swing.JButton();
        jLabel15 = new javax.swing.JLabel();
        txtAtiDtaFinalInicial = new javax.swing.JTextField();
        jLabel16 = new javax.swing.JLabel();
        txtAtiCodigo = new javax.swing.JTextField();
        jLabel17 = new javax.swing.JLabel();
        txtAtiDtaInicialInicial = new javax.swing.JTextField();
        txtAtiDtaInicialFinal = new javax.swing.JTextField();
        jLabel18 = new javax.swing.JLabel();
        jLabel19 = new javax.swing.JLabel();
        btnNovoPlanejado = new javax.swing.JButton();
        txtAtiDescricao = new javax.swing.JTextField();
        jLabel20 = new javax.swing.JLabel();
        jScrollPane3 = new javax.swing.JScrollPane();
        jTable3 = new javax.swing.JTable();
        jLabel21 = new javax.swing.JLabel();
        btnModificarPlanejado = new javax.swing.JButton();
        btnRemoverPlanejado = new javax.swing.JButton();
        btnRealizar = new javax.swing.JButton();
        jPanel4 = new javax.swing.JPanel();
        btnNovoRealizado = new javax.swing.JButton();
        jLabel22 = new javax.swing.JLabel();
        btnPesquisarRealizadas = new javax.swing.JButton();
        jLabel23 = new javax.swing.JLabel();
        txtAtiRealFinalFinal = new javax.swing.JTextField();
        jScrollPane4 = new javax.swing.JScrollPane();
        jTable4 = new javax.swing.JTable();
        jLabel24 = new javax.swing.JLabel();
        txtAtiRealDescricao = new javax.swing.JTextField();
        txtAtiRealFinalInicial = new javax.swing.JTextField();
        jLabel25 = new javax.swing.JLabel();
        jLabel26 = new javax.swing.JLabel();
        txtAtiRealCodigo = new javax.swing.JTextField();
        jLabel27 = new javax.swing.JLabel();
        jLabel28 = new javax.swing.JLabel();
        txtAtiRealDtaInicialInicial = new javax.swing.JTextField();
        txtAtiRealInicialFinal = new javax.swing.JTextField();
        btnRemoverRealizado = new javax.swing.JButton();
        btnModificarRealizado = new javax.swing.JButton();
        btnFechar = new javax.swing.JButton();
        btnDependencias = new javax.swing.JButton();

        setTitle("Consulta Produção");
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowActivated(java.awt.event.WindowEvent evt) {
                formWindowActivated(evt);
            }
            public void windowOpened(java.awt.event.WindowEvent evt) {
                formWindowOpened(evt);
            }
        });

        jTabbedPane1.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                jTabbedPane1StateChanged(evt);
            }
        });

        jPanel1.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                jPanel1FocusGained(evt);
            }
        });

        btnNovaProducao.setIcon(new javax.swing.ImageIcon(getClass().getResource("/praticav/images/add.png"))); // NOI18N
        btnNovaProducao.setText("Nova produção");
        btnNovaProducao.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnNovaProducaoActionPerformed(evt);
            }
        });

        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Código", "Ano de Produção", "Tipo de Uva", "Quantidade a Produzir", ""
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.Integer.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false, false, true
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jTable1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTable1MouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(jTable1);
        jTable1.getColumnModel().getColumn(4).setMaxWidth(0);

        jLabel1.setText("Filtros");

        jTextField1.setText("0");

        jLabel2.setText("Código");

        jLabel3.setText("Ano");

        jLabel5.setText("até");

        jLabel4.setText("Tipo de Uva");

        cbxTipoUva.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        jLabel6.setText("Quantidade");

        jTextField4.setText("0");

        jLabel7.setText("até");

        jTextField5.setText("0");

        btnPesquisarProducao.setIcon(new javax.swing.ImageIcon(getClass().getResource("/praticav/images/Pesquisar.png"))); // NOI18N
        btnPesquisarProducao.setText("Pesquisar");
        btnPesquisarProducao.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnPesquisarProducaoActionPerformed(evt);
            }
        });

        btnModificar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/praticav/images/edit.png"))); // NOI18N
        btnModificar.setText("Modificar");
        btnModificar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnModificarActionPerformed(evt);
            }
        });

        btnRemover.setIcon(new javax.swing.ImageIcon(getClass().getResource("/praticav/images/cancel.png"))); // NOI18N
        btnRemover.setText("Remover");
        btnRemover.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnRemoverActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addGap(35, 35, 35))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 606, Short.MAX_VALUE)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(btnNovaProducao)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(btnModificar)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(btnRemover))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel2))
                                .addGap(18, 18, 18)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel3))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel5)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(cbxTipoUva, javax.swing.GroupLayout.PREFERRED_SIZE, 82, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel4))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(jTextField4, javax.swing.GroupLayout.DEFAULT_SIZE, 56, Short.MAX_VALUE)
                                    .addComponent(jLabel6))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel7)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jTextField5, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 15, Short.MAX_VALUE)
                                .addComponent(btnPesquisarProducao)))
                        .addContainerGap())))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel4)
                            .addComponent(jLabel6))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel5)
                            .addComponent(cbxTipoUva, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jTextField4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel7)
                            .addComponent(jTextField5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(btnPesquisarProducao))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 158, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnNovaProducao)
                    .addComponent(btnModificar)
                    .addComponent(btnRemover, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(27, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Produção", jPanel1);

        jPanel2.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jPanel2MouseClicked(evt);
            }
        });
        jPanel2.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                jPanel2FocusGained(evt);
            }
        });

        jLabel8.setText("até");

        jLabel9.setText("Descrição");

        jLabel10.setText("Data Inicial");

        jLabel11.setText("Código");

        jLabel12.setText("Filtros");

        txtFasCodigo.setText("0");

        jLabel13.setText("até");

        jLabel14.setText("Data Final");

        jTable2.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Código", "Descrição", "Data Inicial", "Data Final"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jTable2.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTable2MouseClicked(evt);
            }
        });
        jScrollPane2.setViewportView(jTable2);

        btnNovaFase.setIcon(new javax.swing.ImageIcon(getClass().getResource("/praticav/images/add.png"))); // NOI18N
        btnNovaFase.setText("Nova fase");
        btnNovaFase.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnNovaFaseActionPerformed(evt);
            }
        });

        btnPesquisarFase.setText("Pesquisar");
        btnPesquisarFase.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnPesquisarFaseActionPerformed(evt);
            }
        });

        btnModificarFase.setIcon(new javax.swing.ImageIcon(getClass().getResource("/praticav/images/edit.png"))); // NOI18N
        btnModificarFase.setText("Modificar");
        btnModificarFase.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnModificarFaseActionPerformed(evt);
            }
        });

        btnRemoverFase.setIcon(new javax.swing.ImageIcon(getClass().getResource("/praticav/images/cancel.png"))); // NOI18N
        btnRemoverFase.setText("Remover");
        btnRemoverFase.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnRemoverFaseActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 606, Short.MAX_VALUE)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(btnNovaFase)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnModificarFase)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(btnRemoverFase))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(txtFasCodigo, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel11))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(txtFasDescricao, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel9))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addComponent(txtFasDtaInicialInicial, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel13)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(txtFasDtaIncialFinal, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(jLabel10))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                                .addComponent(txtFasDtaFinalInicial, javax.swing.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel8)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(txtFasDtaFinalFinal, javax.swing.GroupLayout.PREFERRED_SIZE, 72, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(btnPesquisarFase))
                            .addComponent(jLabel14)))
                    .addComponent(jLabel12))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel12)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addComponent(jLabel11)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(txtFasCodigo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addComponent(jLabel9)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(txtFasDescricao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel10)
                            .addComponent(jLabel14))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtFasDtaInicialInicial, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(txtFasDtaIncialFinal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel13)
                            .addComponent(txtFasDtaFinalInicial, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel8)
                            .addComponent(txtFasDtaFinalFinal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(btnPesquisarFase))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 158, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnNovaFase)
                    .addComponent(btnModificarFase)
                    .addComponent(btnRemoverFase))
                .addContainerGap(32, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Fases", jPanel2);

        jPanel3.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                jPanel3FocusGained(evt);
            }
        });

        btnPesquisarPlanejadas.setText("Pesquisar");
        btnPesquisarPlanejadas.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnPesquisarPlanejadasActionPerformed(evt);
            }
        });

        jLabel15.setText("até");

        jLabel16.setText("até");

        txtAtiCodigo.setText("0");

        jLabel17.setText("Filtros");

        jLabel18.setText("Data Inicial");

        jLabel19.setText("Código");

        btnNovoPlanejado.setIcon(new javax.swing.ImageIcon(getClass().getResource("/praticav/images/add.png"))); // NOI18N
        btnNovoPlanejado.setText("Planejar atividade");
        btnNovoPlanejado.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnNovoPlanejadoActionPerformed(evt);
            }
        });

        jLabel20.setText("Data Final");

        jTable3.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Código", "Descrição", "Data Inicial", "Data Final", "Intervalo Antes", "LeadTime", "Intervalo Após"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jTable3.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTable3MouseClicked(evt);
            }
        });
        jScrollPane3.setViewportView(jTable3);

        jLabel21.setText("Descrição");

        btnModificarPlanejado.setIcon(new javax.swing.ImageIcon(getClass().getResource("/praticav/images/edit.png"))); // NOI18N
        btnModificarPlanejado.setText("Modificar");
        btnModificarPlanejado.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnModificarPlanejadoActionPerformed(evt);
            }
        });

        btnRemoverPlanejado.setIcon(new javax.swing.ImageIcon(getClass().getResource("/praticav/images/cancel.png"))); // NOI18N
        btnRemoverPlanejado.setText("Remover");
        btnRemoverPlanejado.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnRemoverPlanejadoActionPerformed(evt);
            }
        });

        btnRealizar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/praticav/images/Next.png"))); // NOI18N
        btnRealizar.setText("Realizar atividade");
        btnRealizar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnRealizarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 606, Short.MAX_VALUE)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(btnNovoPlanejado)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnModificarPlanejado)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnRemoverPlanejado)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 128, Short.MAX_VALUE)
                        .addComponent(btnRealizar))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(txtAtiCodigo, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel19))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(txtAtiDescricao, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel21))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addComponent(txtAtiDtaInicialInicial, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel16)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(txtAtiDtaInicialFinal, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(jLabel18))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                                .addComponent(txtAtiDtaFinalInicial, javax.swing.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel15)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(txtAtiDtaFinalFinal, javax.swing.GroupLayout.PREFERRED_SIZE, 72, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(btnPesquisarPlanejadas))
                            .addComponent(jLabel20)))
                    .addComponent(jLabel17))
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(jLabel17)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addComponent(jLabel19)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(txtAtiCodigo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addComponent(jLabel21)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(txtAtiDescricao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel18)
                            .addComponent(jLabel20))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtAtiDtaInicialInicial, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(txtAtiDtaInicialFinal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel16)
                            .addComponent(txtAtiDtaFinalInicial, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel15)
                            .addComponent(txtAtiDtaFinalFinal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(btnPesquisarPlanejadas))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 158, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnNovoPlanejado)
                    .addComponent(btnModificarPlanejado)
                    .addComponent(btnRemoverPlanejado)
                    .addComponent(btnRealizar))
                .addContainerGap(32, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Atividades Planejadas", jPanel3);

        jPanel4.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                jPanel4FocusGained(evt);
            }
        });

        btnNovoRealizado.setIcon(new javax.swing.ImageIcon(getClass().getResource("/praticav/images/add.png"))); // NOI18N
        btnNovoRealizado.setText("Realizar atividade não Planejada");
        btnNovoRealizado.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnNovoRealizadoActionPerformed(evt);
            }
        });

        jLabel22.setText("Código");

        btnPesquisarRealizadas.setText("Pesquisar");
        btnPesquisarRealizadas.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnPesquisarRealizadasActionPerformed(evt);
            }
        });

        jLabel23.setText("Data Inicial");

        jTable4.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Código", "Descrição", "Data Inicial", "Data Final", "Planejada"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jTable4.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTable4MouseClicked(evt);
            }
        });
        jTable4.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jTable4KeyPressed(evt);
            }
        });
        jScrollPane4.setViewportView(jTable4);

        jLabel24.setText("até");

        jLabel25.setText("Data Final");

        jLabel26.setText("até");

        txtAtiRealCodigo.setText("0");

        jLabel27.setText("Filtros");

        jLabel28.setText("Descrição");

        btnRemoverRealizado.setIcon(new javax.swing.ImageIcon(getClass().getResource("/praticav/images/cancel.png"))); // NOI18N
        btnRemoverRealizado.setText("Remover");
        btnRemoverRealizado.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnRemoverRealizadoActionPerformed(evt);
            }
        });

        btnModificarRealizado.setIcon(new javax.swing.ImageIcon(getClass().getResource("/praticav/images/edit.png"))); // NOI18N
        btnModificarRealizado.setText("Modificar");
        btnModificarRealizado.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnModificarRealizadoActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 606, Short.MAX_VALUE)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addComponent(btnNovoRealizado)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnModificarRealizado)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnRemoverRealizado))
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(txtAtiRealCodigo, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel22))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(txtAtiRealDescricao, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel28))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel4Layout.createSequentialGroup()
                                .addComponent(txtAtiRealDtaInicialInicial, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel26)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(txtAtiRealInicialFinal, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(jLabel23))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                                .addComponent(txtAtiRealFinalInicial, javax.swing.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel24)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(txtAtiRealFinalFinal, javax.swing.GroupLayout.PREFERRED_SIZE, 72, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(btnPesquisarRealizadas))
                            .addComponent(jLabel25)))
                    .addComponent(jLabel27))
                .addContainerGap())
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addComponent(jLabel27)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(jPanel4Layout.createSequentialGroup()
                                .addComponent(jLabel22)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(txtAtiRealCodigo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel4Layout.createSequentialGroup()
                                .addComponent(jLabel28)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(txtAtiRealDescricao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel23)
                            .addComponent(jLabel25))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtAtiRealDtaInicialInicial, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(txtAtiRealInicialFinal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel26)
                            .addComponent(txtAtiRealFinalInicial, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel24)
                            .addComponent(txtAtiRealFinalFinal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(btnPesquisarRealizadas))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 158, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnNovoRealizado)
                    .addComponent(btnModificarRealizado)
                    .addComponent(btnRemoverRealizado))
                .addContainerGap(32, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Atividades Realizadas", jPanel4);

        btnFechar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/praticav/images/close.png"))); // NOI18N
        btnFechar.setText("Fechar");
        btnFechar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnFecharActionPerformed(evt);
            }
        });

        btnDependencias.setIcon(new javax.swing.ImageIcon(getClass().getResource("/praticav/images/ReportSearch.png"))); // NOI18N
        btnDependencias.setText("Gerar MRP");
        btnDependencias.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnDependenciasActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jTabbedPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 631, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(btnDependencias)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(btnFechar, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 343, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnFechar)
                    .addComponent(btnDependencias, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened
        // TODO add your handling code here:
        mostrarDadosProducao();
        DefaultComboBoxModel cmodel =  
          new DefaultComboBoxModel(  
             new Vector( new TipoUvaDAO().listar() ) 
          );         
        cbxTipoUva.setModel(cmodel); 
        
       jTabbedPane1.setEnabledAt(1, false);
       jTabbedPane1.setEnabledAt(2, false);
       jTabbedPane1.setEnabledAt(3, false);
       btnModificar.setEnabled(false);
       btnRemover.setEnabled(false);
       btnModificarFase.setEnabled(false);
       btnRemoverFase.setEnabled(false); 
       btnDependencias.setEnabled(false);
       
       btnModificarPlanejado.setEnabled(false);
       btnModificarRealizado.setEnabled(false);
       btnRemoverPlanejado.setEnabled(false);
       btnRemoverRealizado.setEnabled(false);
       btnRealizar.setEnabled(false);
    }//GEN-LAST:event_formWindowOpened

    private void jTable1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTable1MouseClicked
        // TODO add your handling code here:
        ProCodigo = Integer.parseInt(""+(jTable1.getValueAt(jTable1.getSelectedRow(), 0)));
        ano = Integer.parseInt(""+(jTable1.getValueAt(jTable1.getSelectedRow(), 1)));
        quant = Integer.parseInt(""+(jTable1.getValueAt(jTable1.getSelectedRow(), 3)));
        tipo = Integer.parseInt(""+(jTable1.getValueAt(jTable1.getSelectedRow(), 4)));
        FasCodigo=0;        
        mostrarDadosFases();
        jTabbedPane1.setEnabledAt(1, true);
        btnModificar.setEnabled(true);
        btnRemover.setEnabled(true);
        btnDependencias.setEnabled(true);
        
        jTabbedPane1.setEnabledAt(2, false);
        jTabbedPane1.setEnabledAt(3, false);
        btnModificarPlanejado.setEnabled(false);
        btnModificarRealizado.setEnabled(false);
        btnRemoverPlanejado.setEnabled(false);
        btnRemoverRealizado.setEnabled(false);
        btnRealizar.setEnabled(false);    
    }//GEN-LAST:event_jTable1MouseClicked

    private void btnNovaProducaoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNovaProducaoActionPerformed
        // Novo
        ProducaoView u = new ProducaoView();
        u.setLocationRelativeTo(null);
        u.setVisible(true);
        mostrarDadosProducao();
    }//GEN-LAST:event_btnNovaProducaoActionPerformed

    private void jPanel1FocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jPanel1FocusGained
        // TODO add your handling code here:
    }//GEN-LAST:event_jPanel1FocusGained

    private void jPanel2FocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jPanel2FocusGained
        mostrarDadosFases();
    }//GEN-LAST:event_jPanel2FocusGained

    private void jPanel3FocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jPanel3FocusGained
        mostrarDadosAtividadesPlanejadas();
    }//GEN-LAST:event_jPanel3FocusGained

    private void jPanel4FocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jPanel4FocusGained
        mostrarDadosAtividadesRealizadas();
    }//GEN-LAST:event_jPanel4FocusGained
    private void jTabbedPane1StateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jTabbedPane1StateChanged
        // TODO add your handling code here:
        //mostrarDadosFases();
    }//GEN-LAST:event_jTabbedPane1StateChanged

    private void jPanel2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jPanel2MouseClicked
        // TODO add your handling code here:
    }//GEN-LAST:event_jPanel2MouseClicked

    private void jTable2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTable2MouseClicked
        FasCodigo = Integer.parseInt(""+(jTable2.getValueAt(jTable2.getSelectedRow(), 0)));
        mostrarDadosAtividadesPlanejadas();
        mostrarDadosAtividadesRealizadas();
        
        jTabbedPane1.setEnabledAt(2, true);
        jTabbedPane1.setEnabledAt(3, true);
        btnModificarFase.setEnabled(true);
        btnRemoverFase.setEnabled(true);

        btnModificarPlanejado.setEnabled(false);
        btnModificarRealizado.setEnabled(false);
        btnRemoverPlanejado.setEnabled(false);
        btnRemoverRealizado.setEnabled(false);
        btnRealizar.setEnabled(false);        
    }//GEN-LAST:event_jTable2MouseClicked

    private void btnFecharActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnFecharActionPerformed
        this.setVisible(false);
    }//GEN-LAST:event_btnFecharActionPerformed

    private void btnPesquisarProducaoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPesquisarProducaoActionPerformed
        mostrarDadosProducao();
    }//GEN-LAST:event_btnPesquisarProducaoActionPerformed

    private void btnPesquisarFaseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPesquisarFaseActionPerformed
        mostrarDadosFases();
    }//GEN-LAST:event_btnPesquisarFaseActionPerformed

    private void btnPesquisarPlanejadasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPesquisarPlanejadasActionPerformed
        mostrarDadosAtividadesPlanejadas();
    }//GEN-LAST:event_btnPesquisarPlanejadasActionPerformed

    private void btnPesquisarRealizadasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPesquisarRealizadasActionPerformed
        mostrarDadosAtividadesRealizadas();
    }//GEN-LAST:event_btnPesquisarRealizadasActionPerformed

    private void btnModificarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnModificarActionPerformed
        // Modify
        Producao p = new ProducaoDAO().buscar(ProCodigo);
        ProducaoView u = new ProducaoView(p);
        u.setLocationRelativeTo(null);
        u.setVisible(true);
        mostrarDadosProducao();
    }//GEN-LAST:event_btnModificarActionPerformed

    private void btnRemoverActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRemoverActionPerformed
        // Remover
        Object[] options = { "Sim", "Não" };  
      int Resposta = JOptionPane.showOptionDialog(null,  
        "Deseja excluir este registro?", "Excluir",  
        JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null,  
        options, options[0]);
        
        if (Resposta == JOptionPane.YES_OPTION){
              Producao a = new Producao();
              a.setProcodigo(ProCodigo);
              ProducaoDAO dao = new ProducaoDAO();
              dao.excluir(a);
              mostrarDadosProducao();
        }
    }//GEN-LAST:event_btnRemoverActionPerformed

    private void formWindowActivated(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowActivated
        mostrarDadosProducao();
        mostrarDadosFases();
        mostrarDadosAtividadesPlanejadas();
        mostrarDadosAtividadesRealizadas();
    }//GEN-LAST:event_formWindowActivated

    private void btnNovaFaseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNovaFaseActionPerformed
        // add
        FasesView f = new FasesView(ProCodigo);
        f.setLocationRelativeTo(null);
        f.setVisible(true);
    }//GEN-LAST:event_btnNovaFaseActionPerformed

    private void jTable3MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTable3MouseClicked
        AtiPlanCodigo = Integer.parseInt(""+jTable3.getValueAt(jTable3.getSelectedRow(), 0));
        
       btnModificarPlanejado.setEnabled(true);
       btnRemoverPlanejado.setEnabled(true);
       btnRealizar.setEnabled(true);
    }//GEN-LAST:event_jTable3MouseClicked

    private void btnModificarFaseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnModificarFaseActionPerformed
        FasesPK chave = new FasesPK();
        chave.setFascodigo(FasCodigo);
        chave.setProducao(new ProducaoDAO().buscar(ProCodigo));
        Fases fas = new FasesDAO().buscar(chave);
        FasesView f = new FasesView(fas);
        f.setLocationRelativeTo(null);
        f.setVisible(true);
    }//GEN-LAST:event_btnModificarFaseActionPerformed

    private void btnDependenciasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDependenciasActionPerformed
        // TODO add your handling code here:
        Predecessores pred = new Predecessores(ProCodigo);
        pred.setLocationRelativeTo(null);
        pred.setVisible(true);
    }//GEN-LAST:event_btnDependenciasActionPerformed

    private void btnModificarPlanejadoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnModificarPlanejadoActionPerformed
        // TODO add your handling code here:
        AtividadesPlanejadasPK chave = new AtividadesPlanejadasPK();
        chave.setAtiplanCodigo(AtiPlanCodigo);
        FasesPK fasePK = new FasesPK();
        fasePK.setFascodigo(FasCodigo);
        fasePK.setProducao(new ProducaoDAO().buscar(ProCodigo));
        Fases fase = new FasesDAO().buscar(fasePK);
        chave.setFase(fase);
        AtividadesPlanejadas ap = new AtividadesPlanejadasDAO().buscar(chave);
        AtividadesPlanejadasView apView = new AtividadesPlanejadasView(ap);
        apView.setLocationRelativeTo(null);
        apView.setVisible(true);
        mostrarDadosAtividadesPlanejadas();
    }//GEN-LAST:event_btnModificarPlanejadoActionPerformed

    private void btnNovoPlanejadoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNovoPlanejadoActionPerformed
        // TODO add your handling code here:
        AtividadesPlanejadasView apView = new AtividadesPlanejadasView(ProCodigo, FasCodigo);
        apView.setLocationRelativeTo(null);
        apView.setVisible(true);      
        mostrarDadosAtividadesPlanejadas();
    }//GEN-LAST:event_btnNovoPlanejadoActionPerformed

    private void btnRemoverFaseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRemoverFaseActionPerformed
        // TODO add your handling code here:
        Object[] options = { "Sim", "Não" };  
      int Resposta = JOptionPane.showOptionDialog(null,  
        "Deseja excluir este registro?", "Excluir",  
        JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null,  
        options, options[0]);
        
        if (Resposta == JOptionPane.YES_OPTION){
              FasesPK chave = new FasesPK();
              Producao p = new ProducaoDAO().buscar(ProCodigo);
              chave.setFascodigo(FasCodigo);
              chave.setProducao(p);
              Fases f = new Fases();
              f.setChave(chave);
              FasesDAO dao = new FasesDAO();
              dao.excluir(f);
              mostrarDadosFases();
        }        
    }//GEN-LAST:event_btnRemoverFaseActionPerformed

    private void btnRemoverPlanejadoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRemoverPlanejadoActionPerformed
        // TODO add your handling code here:
        Object[] options = { "Sim", "Não" };  
      int Resposta = JOptionPane.showOptionDialog(null,  
        "Deseja excluir este registro?", "Excluir",  
        JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null,  
        options, options[0]);
        
        if (Resposta == JOptionPane.YES_OPTION){
              FasesPK chave = new FasesPK();
              Producao p = new ProducaoDAO().buscar(ProCodigo);
              chave.setFascodigo(FasCodigo);
              chave.setProducao(p);
              Fases f = new FasesDAO().buscar(chave);
              AtividadesPlanejadasPK atChave = new AtividadesPlanejadasPK();
              atChave.setAtiplanCodigo(AtiPlanCodigo);
              atChave.setFase(f);
              AtividadesPlanejadas at = new AtividadesPlanejadas();
              at.setChave(atChave);
              AtividadesPlanejadasDAO dao = new AtividadesPlanejadasDAO();
              dao.excluir(at);
              mostrarDadosAtividadesPlanejadas();
        }             
    }//GEN-LAST:event_btnRemoverPlanejadoActionPerformed

    private void btnNovoRealizadoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNovoRealizadoActionPerformed
        // TODO add your handling code here:
        AtividadesRealizadasView arView = new AtividadesRealizadasView(ProCodigo, FasCodigo);
        arView.setLocationRelativeTo(null);
        arView.setVisible(true);         
    }//GEN-LAST:event_btnNovoRealizadoActionPerformed

    private void btnModificarRealizadoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnModificarRealizadoActionPerformed
        // TODO add your handling code here:

        Producao p = new ProducaoDAO().buscar(ProCodigo);
        FasesPK chaveFase = new FasesPK();
        chaveFase.setFascodigo(FasCodigo);
        chaveFase.setProducao(p);
        Fases f = new FasesDAO().buscar(chaveFase);
        
        AtividadesRealizadasPK chaveAR = new AtividadesRealizadasPK();
        chaveAR.setAtirealcodigo(AtiRelCodigo);        
        chaveAR.setFase(f);
        AtividadesRealizadas ar = new AtividadesRealizadasDAO().buscar(chaveAR);
        AtividadesRealizadasView arView = new AtividadesRealizadasView(ar);
        arView.setLocationRelativeTo(null);
        arView.setVisible(true);         
    }//GEN-LAST:event_btnModificarRealizadoActionPerformed

    private void jTable4KeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTable4KeyPressed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTable4KeyPressed

    private void jTable4MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTable4MouseClicked
        // TODO add your handling code here:
        AtiRelCodigo = Integer.parseInt(""+jTable4.getValueAt(jTable4.getSelectedRow(), 0));
       btnModificarRealizado.setEnabled(true);
       btnRemoverRealizado.setEnabled(true);
    }//GEN-LAST:event_jTable4MouseClicked

    private void btnRemoverRealizadoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRemoverRealizadoActionPerformed
        // TODO add your handling code here:
        Object[] options = { "Sim", "Não" };  
      int Resposta = JOptionPane.showOptionDialog(null,  
        "Deseja excluir este registro?", "Excluir",  
        JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null,  
        options, options[0]);
        
        if (Resposta == JOptionPane.YES_OPTION){
              FasesPK chave = new FasesPK();
              Producao p = new ProducaoDAO().buscar(ProCodigo);
              chave.setFascodigo(FasCodigo);
              chave.setProducao(p);
              Fases f = new FasesDAO().buscar(chave);
              AtividadesRealizadasPK atChave = new AtividadesRealizadasPK();
              atChave.setAtirealcodigo(AtiRelCodigo);
              atChave.setFase(f);
              AtividadesRealizadas at = new AtividadesRealizadas();
              at.setChave(atChave);
              AtividadesRealizadasDAO dao = new AtividadesRealizadasDAO();
              dao.excluir(at);
              mostrarDadosAtividadesRealizadas();
        }          
    }//GEN-LAST:event_btnRemoverRealizadoActionPerformed

    private void btnRealizarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRealizarActionPerformed
        // TODO add your handling code here:
        AtividadesPlanejadasPK chave = new AtividadesPlanejadasPK();
        chave.setAtiplanCodigo(AtiPlanCodigo);
        FasesPK fasePK = new FasesPK();
        fasePK.setFascodigo(FasCodigo);
        fasePK.setProducao(new ProducaoDAO().buscar(ProCodigo));
        Fases fase = new FasesDAO().buscar(fasePK);
        chave.setFase(fase);
        
        AtividadesPlanejadas ap = new AtividadesPlanejadasDAO().buscar(chave);
        AtividadesRealizadas rel = new AtividadesRealizadas();
        AtividadesRealizadasPK pkRel = new AtividadesRealizadasPK();
        pkRel.setFase(fase);
        rel.setChave(pkRel);
        rel.setAtiplancodigo(AtiPlanCodigo);
        rel.setAtirealdescricao(ap.getAtiplandescricao());
        rel.setAtirealdtafinal(ap.getAtiplandtafinal());
        rel.setAtirealdtainicial(ap.getAtiplandtainicial());
        AtividadesRealizadasDAO daoRel = new AtividadesRealizadasDAO();
        daoRel.inserir(rel);
        AtividadesRealizadasView apView = new AtividadesRealizadasView(rel);
        apView.setLocationRelativeTo(null);
        apView.setVisible(true);
    }//GEN-LAST:event_btnRealizarActionPerformed
    
    public void mostrarDadosProducao(){
        //Prepara tabela
        DefaultTableModel modeloProducao = (DefaultTableModel) jTable1.getModel();
        modeloProducao.setNumRows(0);

        //Objetos
        ProducaoDAO daoProducao = new ProducaoDAO();

        for (Producao p : daoProducao.listar()) { 
          modeloProducao.addRow(new String[] {""+ p.getProcodigo(), "" + p.getProano(),""+ p.getTipouva().getUvadescricao(), "" + p.getProquantidade(), "" + p.getTipouva().getUvacodigo()});
        }
    }
    public void mostrarDadosFases(){
        //Prepara tabela
        DefaultTableModel modeloFase = (DefaultTableModel) jTable2.getModel();
        modeloFase.setNumRows(0);

        //Objetos
        FasesDAO daoFase = new FasesDAO();

        for (Fases f : daoFase.listar(ProCodigo, Integer.parseInt(""+txtFasCodigo.getText()), txtFasDescricao.getText(), txtFasDtaInicialInicial.getText(), txtFasDtaIncialFinal.getText(), txtFasDtaFinalInicial.getText(), txtFasDtaFinalFinal.getText())) { 
          modeloFase.addRow(new String[] {""+ f.getChave().getFascodigo(), ""+ f.getFasdescricao(), "" + f.getFasdtainicial(), "" + f.getFasdtafinal()});
        }
    }
    public void mostrarDadosAtividadesPlanejadas(){
        //Prepara tabela
        DefaultTableModel modeloAtividadesPlanejadas = (DefaultTableModel) jTable3.getModel();
        modeloAtividadesPlanejadas.setNumRows(0);

        //Objetos
        AtividadesPlanejadasDAO daoAtividadesPlanejadas = new AtividadesPlanejadasDAO();

        for (AtividadesPlanejadas ap : daoAtividadesPlanejadas.listar(ProCodigo, FasCodigo, Integer.parseInt(txtAtiCodigo.getText()), txtAtiDescricao.getText(), txtAtiDtaInicialInicial.getText(), txtAtiDtaInicialFinal.getText(), txtAtiDtaFinalInicial.getText(), txtAtiDtaFinalFinal.getText())) { 
        //for (AtividadesPlanejadas ap : daoAtividadesPlanejadas.listar()) { 
          modeloAtividadesPlanejadas.addRow(new String[] {""+ ap.getChave().getAtiplanCodigo(), ""+ ap.getAtiplandescricao(), "" + ap.getAtiplandtainicial(), "" + ap.getAtiplandtafinal(), "" + ap.getAtiplanintervaloantes(), "" + ap.getAtiplanleadtime(), "" + ap.getAtiplanintervalodepois()});
        }
    }    
    public void mostrarDadosAtividadesRealizadas(){
        //Prepara tabela
        DefaultTableModel modeloAtividadesRealizadas = (DefaultTableModel) jTable4.getModel();
        modeloAtividadesRealizadas.setNumRows(0);

        //Objetos
        AtividadesRealizadasDAO daoAtividadesRealizadas = new AtividadesRealizadasDAO();

        for (AtividadesRealizadas ar : daoAtividadesRealizadas.listar(ProCodigo, FasCodigo, Integer.parseInt(txtAtiCodigo.getText()), txtAtiDescricao.getText(), txtAtiDtaInicialInicial.getText(), txtAtiDtaInicialFinal.getText(), txtAtiDtaFinalInicial.getText(), txtAtiDtaFinalFinal.getText())) { 
          String PlanDescricao="";
          if(ar.getAtiplancodigo()!=0){
              AtividadesPlanejadasPK atPK = new AtividadesPlanejadasPK();
              FasesPK fasePK = new FasesPK();
              Producao p = new ProducaoDAO().buscar(ar.getChave().getFase().getChave().getProducao().getProcodigo());
              fasePK.setProducao(p);
              fasePK.setFascodigo(ar.getChave().getFase().getChave().getFascodigo());
              //atPK.setProcodigo(ar.getChave().getProcodigo());
              //atPK.setFascodigo(ar.getChave().getFascodigo());
              Fases fase = new FasesDAO().buscar(fasePK);
              atPK.setFase(fase);
              atPK.setAtiplanCodigo(ar.getAtiplancodigo());
              AtividadesPlanejadas ap = new AtividadesPlanejadasDAO().buscar(atPK);                         
              PlanDescricao = ap.getAtiplandescricao();
          }
          modeloAtividadesRealizadas.addRow(new String[] {""+ ar.getChave().getAtirealcodigo(), ""+ 
                                                              ar.getAtirealdescricao(), "" + 
                                                              ar.getAtirealdtainicial(), "" + 
                                                              ar.getAtirealdtafinal(), "" + 
                                                              //ar.getAtividadesPlanejadas().getAtiplandescricao()});
                                                              PlanDescricao});
        }
    }    
    /**
     * @param args the command line arguments
     */
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnDependencias;
    private javax.swing.JButton btnFechar;
    private javax.swing.JButton btnModificar;
    private javax.swing.JButton btnModificarFase;
    private javax.swing.JButton btnModificarPlanejado;
    private javax.swing.JButton btnModificarRealizado;
    private javax.swing.JButton btnNovaFase;
    private javax.swing.JButton btnNovaProducao;
    private javax.swing.JButton btnNovoPlanejado;
    private javax.swing.JButton btnNovoRealizado;
    private javax.swing.JButton btnPesquisarFase;
    private javax.swing.JButton btnPesquisarPlanejadas;
    private javax.swing.JButton btnPesquisarProducao;
    private javax.swing.JButton btnPesquisarRealizadas;
    private javax.swing.JButton btnRealizar;
    private javax.swing.JButton btnRemover;
    private javax.swing.JButton btnRemoverFase;
    private javax.swing.JButton btnRemoverPlanejado;
    private javax.swing.JButton btnRemoverRealizado;
    private javax.swing.JComboBox cbxTipoUva;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel24;
    private javax.swing.JLabel jLabel25;
    private javax.swing.JLabel jLabel26;
    private javax.swing.JLabel jLabel27;
    private javax.swing.JLabel jLabel28;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JTable jTable1;
    private javax.swing.JTable jTable2;
    private javax.swing.JTable jTable3;
    private javax.swing.JTable jTable4;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JTextField jTextField2;
    private javax.swing.JTextField jTextField3;
    private javax.swing.JTextField jTextField4;
    private javax.swing.JTextField jTextField5;
    private javax.swing.JTextField txtAtiCodigo;
    private javax.swing.JTextField txtAtiDescricao;
    private javax.swing.JTextField txtAtiDtaFinalFinal;
    private javax.swing.JTextField txtAtiDtaFinalInicial;
    private javax.swing.JTextField txtAtiDtaInicialFinal;
    private javax.swing.JTextField txtAtiDtaInicialInicial;
    private javax.swing.JTextField txtAtiRealCodigo;
    private javax.swing.JTextField txtAtiRealDescricao;
    private javax.swing.JTextField txtAtiRealDtaInicialInicial;
    private javax.swing.JTextField txtAtiRealFinalFinal;
    private javax.swing.JTextField txtAtiRealFinalInicial;
    private javax.swing.JTextField txtAtiRealInicialFinal;
    private javax.swing.JTextField txtFasCodigo;
    private javax.swing.JTextField txtFasDescricao;
    private javax.swing.JTextField txtFasDtaFinalFinal;
    private javax.swing.JTextField txtFasDtaFinalInicial;
    private javax.swing.JTextField txtFasDtaIncialFinal;
    private javax.swing.JTextField txtFasDtaInicialInicial;
    // End of variables declaration//GEN-END:variables
}
